package com.etone.smartAudit.utils.Excel;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author: sovy
 * @date: 2019-01-25 17:57:34
 * @description:
 */
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
@ApiModel(value = "导入错误信息")
public class ImportErrorInfo implements Serializable {
    @ApiModelProperty("所在行")
    private Integer row;

    @ApiModelProperty("所在列")
    private Integer column;

    @ApiModelProperty("所在列表头")
    private String head;

    @ApiModelProperty("错误信息")
    private String message;

    @ApiModelProperty("错误信息,不带样式")
    private String messageNoStyle;

    @ApiModelProperty("错误信息，不带行号")
    private String messageNoRow;


    public static ImportErrorInfo buildMessage(String message) {
        return ImportErrorInfo
                .builder()
                .message(message)
                .messageNoStyle(message)
                .messageNoRow(message)
                .build();
    }

    public static ImportErrorInfo buildMessage(Integer row, Integer column, String head, String message) {
        return ImportErrorInfo
                .builder()
                .row(row)
                .column(column)
                .head(head)
                .message("<br/>第<span style='color:red'>" + row + "</span>行<span style='color:red'>" + head + "</span>" + message + ";")
                .messageNoStyle("第" + row + "行" + head + message + ";")
                .messageNoRow(head + message)
                .build();
    }

    /**
     * 文本空错误
     *
     * @param row
     * @param column
     * @param head
     * @return
     */
    public static ImportErrorInfo bankError(Integer row, Integer column, String head) {
        return buildMessage(row, column, head, "为空");
    }

    /**
     * 手机号码错误
     *
     * @param row
     * @param column
     * @param head
     * @return
     */
    public static ImportErrorInfo formatError(Integer row, Integer column, String head) {
        return buildMessage(row, column, head, "格式错误");
    }

    /**
     * 值不存在
     *
     * @param row
     * @param column
     * @param head
     * @return
     */
    public static ImportErrorInfo valueNotExists(Integer row, Integer column, String head) {
        return buildMessage(row, column, head, "不存在");
    }
}